#include<bits/stdc++.h>
using namespace std;
int n,a[200005],ans=0;
int f[200005];
int t;
int findans()
{
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int k=-1;
		for(int j=1;j<i;j++)
		{
			if(f[j]==f[i]) k=j;
		}
		if(k!=-1&&a[i]==a[k]) ans+=a[i];
	}
	return ans;
}
void dfs(int dep)
{
	if(dep>n)
	{
		int t=findans();
		ans=max(ans,t);
		return ;
	}
	f[dep]=1;
	dfs(dep+1);
	f[dep]=-1;
	
	f[dep]=0;
	dfs(dep+1);
	f[dep]=-1;
}
int main()
{
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	scanf("%d",&t);
	while(t--)
	{	
		ans=0;
		memset(a,0,sizeof(a));
		memset(f,-1,sizeof(f));
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%d",&a[i]);
		dfs(1);
		printf("%d\n",ans);
	}
	return 0;
}
